﻿
using EFCoreLockStudy1;
using Microsoft.EntityFrameworkCore;

using var db = new SqlDbContext();
using var trans = db.Database.BeginTransaction();
Console.WriteLine("修改前：");
var house = db.Houses.FromSql($"select * from T_house where id =1").AsNoTracking().Single();
Console.WriteLine(house.Owner);

Console.WriteLine("修改后：");
house = db.Houses.FromSql($"select * from T_house where id =1").AsNoTracking().Single();
Console.WriteLine(house.Owner);

trans.Commit();

Console.WriteLine("事务提交后：");
   // db.Entry(house).Reload();
house = db.Houses.FromSql($"select * from T_house where id =1").AsNoTracking().Single();
Console.WriteLine(house.Owner);
Console.ReadKey();
